/*
 * @Author: moeWang
 * @Date: 2022-03-07 14:04:55
 * @LastEditTime: 2022-03-08 09:37:22
 * @LastEditors: moeWang
 * @Description:
 * @FilePath: \nest-web\src\logical\menu\entity\menu.entity.ts
 */

import {
  BelongsToMany,
  Column,
  ForeignKey,
  HasMany,
  Model,
  PrimaryKey,
  Table,
} from 'sequelize-typescript';
import { DataTypes } from 'sequelize';
// import { RoleMenuEntity } from 'src/logical/role/entity/role.entity';
import { Col } from 'sequelize/types/utils';
import {
  RoleEntity,
  RoleMenuEntity,
} from 'src/logical/role/entity/role.entity';

@Table({
  tableName: 'rp_menu',
  timestamps: false,
})
export class MenuEntity extends Model<MenuEntity> {
  @PrimaryKey
  @Column({
    type: DataTypes.BIGINT,
    field: 'menu_id',
  })
  menuId: string;

  //   @HasMany(() => MenuEntity)
  //   @Column
  //   children: MenuEntity[];

  //   @BelongsToMany(() => MenuEntity, () => MenuEntity)
  //   @Column
  //   menuPId: MenuEntity;

  @ForeignKey(() => MenuEntity)
  @Column({
    field: 'menupid',
  })
  menuPId: string;

  @BelongsToMany(() => RoleEntity, () => RoleMenuEntity)
  roles: RoleEntity[];

  // @BelongsToMany(() => MenuEntity, () => MenuEntity)
  // children: MenuEntity[];

  // @BelongsToMany(() => MenuEntity, () => RoleMenuEntity)
  // menus: MenuEntity[];
  @Column({
    field: 'menu_name',
  })
  menuName: string;
  @Column({
    field: 'menu_code',
  })
  menuCode: string;
  @Column
  icon: string;
  @Column({
    field: 'menu_type',
  })
  menuType: string;
  @Column({
    type: DataTypes.TINYINT,
  })
  sort: number;
}
